package com.my.study.jdbc.service.impl;

import com.my.study.jdbc.aop.MultiTransactional;
import com.my.study.jdbc.dao.AccountDao;
import com.my.study.jdbc.entity.Account;
import com.my.study.jdbc.entity.BookEntity;
import com.my.study.jdbc.service.BookService;
import com.my.study.jdbc.service.MultiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Carlos
 * @version 1.0
 * @Description TODO
 * @date 2021/11/7 14:02
 **/
@Service
public class MultiServiceImpl implements MultiService {

    @Autowired
    private AccountDao accountDao;

    @Autowired
    private BookService bookService;


    @Override
    @MultiTransactional(value = {"transactionManagerOne", "transactionManagerTwo"})
    public void multiUpdate(Account account, BookEntity book) {
        accountDao.updateMoneyById(account);
        int i = 1 / 0 ;
        bookService.update(book);
    }
}
